﻿<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>工序不合格原因维护</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style>
        .easyui-linkbutton{margin-left:20px;}
        table tr td{padding:0px 5px}
       #fm .l-btn-text{margin-top:3px}
       .tdlabel{text-align:right;padding:5px;}
       .divLabel{padding:10px 0;}
    </style>
</head>
<body>
 <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:5px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <form id="searchForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td>批次号:</td>
                    <td><input  name="CONTAINERNO" class="easyui-textbox" style="width: 120px; height: 22px"/></td>
                    <td>工序号:</td>
                    <td><input  name="SPENO" class="easyui-textbox" style="width: 120px; height: 22px"/></td>
                    <td>不合格特征:</td>
                    <td><input  name="UNQUALIFIEDFEATURE" class="easyui-textbox" style="width: 120px; height: 22px"/></td>
                    <td>原因唯一代码:</td>
                    <td><input  name="UNIQUECODE" class="easyui-textbox" style="width: 120px; height: 22px"/></td>
                    <td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchData()">查询</a></td>
	    			<td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchReset()">重置</a></td>
	    		</tr>
	    	</table>
	    </form>
        </div> 
    </div>
    <div class="panelSection">
          <div class="easyui-panel " title="工序不合格原因维护" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <table id="UnqualifiedReasonSpec" style="height:440px" data-options="rownumbers:true"></table>
            <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                     buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]
                ">
                    </div>
          <!--   <div style="margin-top:7px">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.createEditUnqualifiedReason(0)">新增</a>
             </div>-->
             </div>
    </div>
    <!-- 创建编辑弹窗-->
    <div id="dd" style="display:none">
         <form id="ceForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td class="tdlabel">唯一代码:</td>
                    <td><input  name="UNIQUECODE" class="easyui-textbox" style="width: 160px;height: 22px;" data-options="onChange:page.getUnqualifiedReason"/></td>
                    <td class="tdlabel">代码名称:</td>
                    <td><input  name="REASONCODENAME" class="easyui-textbox" style="width: 160px; height: 22px" data-options="onChange:page.getUnqualifiedReason"/></td>
                    <td rowspan="2"><a href="javascript:void(0)" class="easyui-linkbutton" style="margin:0" onclick="page.getUnqualifiedReason()">查询</a></td>
	    		</tr>
                <tr class="divLabel">
                    <td class="tdlabel">分类说明:</td>
                    <td><input  name="REASONSORTDES" class="easyui-textbox" style="width: 160px; height: 22px" data-options="onChange:page.getUnqualifiedReason"/></td>
                    <td class="tdlabel">细类说明:</td>
                    <td><input  name="REASONSUBCLASSDES" class="easyui-textbox" style="width: 160px; height: 22px"  data-options="onChange:page.getUnqualifiedReason"/></td>
                </tr>
	    	</table>
            </form>
            <table id="Table1" style="height:200px""></table>
            <div class="tdlabel" style="margin:10px 20px 0 0">
                    <input type=hidden id="UNQUALIFIEDREASONID" name="UNQUALIFIEDREASONID"/>
                 <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.saveUnqualifiedReasonCode()">确定</a>
                 <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#dd').dialog('close')">取消</a>
            </div>
    </div>
     <!--信息提示区域-->
    <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    //创建人：longb
    //日期：2023-12-21
    //描述：排故单附页查看
    var page = {
        pagetotal: 0,
        pageSize: 20,
        pageNumber: 1,
        checkinfoid:null,
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/UnqualifiedHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
       
        //页面事件绑定
        bind: function () {
            $('#UnqualifiedReasonSpec').datagrid({
                checkOnSelect: false,
                selectOnCheck: false,
                singleSelect: true,
                rownumbers: true,
                columns: [[
                 { field: 'MFGORDERNAME', title: '生产订单', width: 120,align:'center' },
                 { field: 'CONTAINERNAME', title: '件号/批次号', width: 100,align:'center' },
		         { field: 'PRODUCTDESCRIPTION', title: '件号名称', width: 120 ,align:'center'},
                 { field: 'PRODUCTREVISION', title: '件号版本', width: 60 ,align:'center'},
                 { field: 'WORKFLOWINFO', title: '工艺版次', width: 150,align:'center' },
                 { field: 'SPECNO', title: '工序号', width: 90 ,align:'center'},
                 { field: 'WORKFLOWSTEPNAME', title: '工序名称', width: 120,align:'center' },
                 { field: 'UNQUALIFIEDREASONCODEEMPNAME', title: '操作者', width: 70 ,align:'center'},
                 { field: 'CHECKERNAME', title: '检验员', width: 70,align:'center' },
                 { field: 'REWORKQTY', title: '返修数', width: 70 ,align:'center'},
                 { field: 'UNQUALIFIEDFEATURE', title: '不合格特征', width: 200,align:'center' },
                 { field: 'UNQUALIFIEDREASONCODE', title: '不合格原因代码', width: 300,align:'center' }
                ]],
                onClickCell:function(index,field,value){
                    if(field=="UNQUALIFIEDREASONCODE"){
                        page.checkinfoid=$('#UnqualifiedReasonSpec').datagrid('getRows')[index].CONTAINERCHECKINFOID
                        page.createEditUnqualifiedReason(index,value);
                    }
                },
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pagetotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.getSpecUnqualifiedReason();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.getSpecUnqualifiedReason();
            });

             $('#Table1').datagrid({
                 columns: [[
                 { field:'ck',checkbox:true},
                 { field: 'UNIQUECODE', title: '唯一代码', width: 100,align:'center' },
                 { field: 'REASONCODENAME', title: '代码名称', width: 100,align:'center' },
		         { field: 'REASONSORTDES', title: '分类说明', width: 130 ,align:'center'},
                 { field: 'REASONSUBCLASSDES', title: '细类说明', width: 150 ,align:'center'}]]
             });
        },
        //查询
        searchData: function () {
            clearMessage();
            page.pageNumber = 1;
            page.getSpecUnqualifiedReason();
        },
        //查询重置
        searchReset: function () {
            $('#searchForm').form('clear');
            clearMessage();
        },
        getSpecUnqualifiedReason:function(){
            var frdata = $('#searchForm').serializeArray();
            var data = {};
            $.each(frdata, function () {
                data[this.name] = this.value
            });
            var param = {
                action: "getSpecUnqualifiedReason",
                pageSize: page.pageSize,
                pageNumber: page.pageNumber,
                data: JSON.stringify(data)
            };
            page.post(param, function (res) {
                if (res.Result) {
                    page.pagetotal = res.RowCount;
                    $('#UnqualifiedReasonSpec').datagrid('loadData', res.DBTable);
                }
            });
        },
        createEditUnqualifiedReason:function(index,value){
//            if(index==1){
//                var row=$('#UnqualifiedReasonSpec').datagrid('getChecked');
//                if(row.length==0||row.length>1){displayMessage("请选择一行数据再进行操作",false);return;}
//                $('#ceForm').form('load',row[0]);
//            }
            var row=$('#UnqualifiedReasonSpec').datagrid('getRows');
             $('#ceForm').form('load',row[index]);
            $('#dd').dialog({
                title: (index==0?'新增':'编辑')+'原因代码',
                width: 550,
                height: 350,
                closed: false,
                cache: false,
                modal: true
            });
        
        },
        saveUnqualifiedReasonCode:function(){
            var rows= $('#Table1').datagrid('getChecked');
            if(rows.length==0){return;}
            var codes =[] ;
            $.each(rows,function(i,item){
                codes.push(item.UNIQUECODE);
            });
            var param={
                action:'saveSpecUnqualifiedReasonCode',
                codes:codes.join(','),
                checkinfoid:page.checkinfoid
            }
            page.post(param, function (res) {
                if (res.Result) {
                   $('#dd').dialog('close');
                   $('#ceForm').form('clear');
                   page.getSpecUnqualifiedReason();
                }
                 displayMessage(res.Message, res.Result);
            });
        },
        getUnqualifiedReason:function(n,o){
            var frdata = $('#ceForm').serializeArray();
            var data = {};
            $.each(frdata, function () {
                data[this.name] = this.value
            });
            var param = {
                action: "getUnqualifiedReason",
                pageSize: 10000,
                pageNumber: 1,
                data: JSON.stringify(data)
            };
            page.post(param, function (res) {
                if (res.Result) {
                    $('#Table1').datagrid('loadData', res.DBTable);
                }
            });
        },

        //post数据
        post: function (param, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        }
    }
    $(function () {
        page.init();
    });
</script>
